package cn.lyd.base.enm;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum OrderStateEnum {
    //收购订单状态：0 待处理 1完成  2取消
    ORDER(0,"待处理"),
    ORDER_SUCCESS(1,"完成"),
    ORDER_CANCEL(2,"取消");

    public static String getNameByCode(Integer code){
        Optional<OrderStateEnum> first = Arrays.stream(OrderStateEnum.values()).filter(state -> state.getCode() == code)
                .findFirst();
        return first.isPresent()?first.get().getName():"";
    }

    private int code;

    private String name;
}
